<?php
include_once 'includes/db_connect.php';
include_once 'includes/functions.php';
 
sec_session_start();
 
if (login_check($mysqli) == true) {
    header('Location: index.php');
} else {
    $loggedIn = false;
}
?>
<!DOCTYPE html>
<html>
    <head>
        <title>Login</title>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
        <script type="text/JavaScript" src="js/sha512.js"></script> 
        <script type="text/JavaScript" src="js/forms.js"></script>
        <link rel="stylesheet" type="text/css" href="resources/css/default.css">
    </head>
    <body>
        <?php
        if (isset($_GET['error'])) {
            echo '<p class="error">Error Logging In!</p>';
        }
        ?>
        <header id="header"><a href="index.php"><img id="logo" src="resources/images/myshoppinglist-logo.png"></a></header>
        <div id="content-wrapper">
            <article id="content">
                <form action="includes/process_login.php" method="post" name="login_form">
                    <table id="login-wrapper">
                        <tr>
                            <td>Email:</td>
                            <td><input type="text" name="email"/></td>
                        </tr>
                        <tr>
                            <td>Password:</td>
                            <td><input type="password" name="password" id="password"/></td>
                        </tr>
                        <tr>
                            <td><input type="button" value="Login" onclick="formhash(this.form, this.form.password);"/></td>
                            <td><input type="button" value="Register" onclick="location.href='register.php'"/></td>
                        </tr>
                    </table>
                </form>
                <div></div>
            </article>
        </div>
        <?php include 'resources/templates/footer.php' ?>
    </body>
</html>